#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
  (ros:ensure-asdf)
  #+quicklisp(ql:quickload '(:lilu-swank/client :lilu-debugger/emacs :lilu-roswell) :silent t))

(defpackage :ros.script.lilu-server.3766064849
  (:use :cl))
(in-package :ros.script.lilu-server.3766064849)

(opts:define-opts
  #.lilu-roswell:*default-help-option*
  #.(lilu-roswell:merge-options
     lilu-roswell:*default-swank-port-option*
     '(:default lilu-swank:*default-swank-port*))
  #.(lilu-roswell:merge-options
     lilu-roswell:*default-swank-host-option*
     '(:default lilu-swank:*default-swank-host*))
  (:name :quit
   :description "quit swank server"
   :required nil
   :default nil
   :short #\q
   :long "quit")
  #.lilu-roswell:*default-debugger-option*
  )

(defun main (&rest argv)
  (lilu-roswell:init-debugging)
  (multiple-value-bind (options free-args)
      (lilu-roswell:parse-options argv :free-args-p t :max-free-args 1 :min-free-args 1)
    (lilu-roswell:options-check-for-help options
                                         :prefix "connect to a swank server and evalute a script"
                                         :suffix "so that's how it works…"
                                         :usage-of "lilu-swank-script.ros"
                                         :args "SCRIPT")
    (let ((args (lilu-roswell:options-get-keys options :port :host :debugger)))
      (lilu-debugger:with-debugger (:abort)
        (apply #'lilu-swank:remote-eval-script (car free-args) args))
      (when (lilu-roswell:options-get-value options :quit)
        (lilu-swank:remote-eval-strings "(lilu-roswell:cl-quit)")))))

;;; vim: set ft=lisp lisp:
